<template>
  <div id="ProfileView">
    <a-row :gutter="[24, 24]">
      <a-col :md="12" :xs="24">
        <a-tabs default-active-key="question">
          <a-tab-pane key="profile" title="主页">
            <a-card></a-card>
          </a-tab-pane>
          <a-tab-pane key="mySubmit" title="我的提交" disabled></a-tab-pane>
        </a-tabs>
      </a-col>
    </a-row>
  </div>
</template>

<script setup lang="ts">
import {
  onMounted,
  ref,
  watchEffect,
  withDefaults,
  defineProps,
  computed,
} from "vue";
import {
  Question,
  QuestionControllerService,
  QuestionSubmitAddRequest,
  QuestionVO,
} from "../../../generated";
import message from "@arco-design/web-vue/es/message";
import CodeEditor from "@/components/CodeEditor.vue";
import MdViewer from "@/components/MdViewer.vue";
import { useRouter } from "vue-router";

const router = useRouter();

interface Props {
  id: string;
}

const props = withDefaults(defineProps<Props>(), {
  id: () => "",
});

const question = ref<QuestionVO>();
const codeLanguage = computed(() => {
  if (form.value.language === "c++") {
    return "cpp";
  }
  return form.value.language;
});

const loadData = async () => {
  const res = await QuestionControllerService.getQuestionVoByIdUsingGet(
    props.id as any
  );
  if (res.code === 0) {
    question.value = res.data;
  } else {
    message.error("加载失败，" + res.message);
  }
};

const form = ref<QuestionSubmitAddRequest>({
  language: "c++",
  code: "",
});

/**
 * 页面加载时，请求数据
 */
onMounted(() => {
  loadData();
});
const goBack = () => {
  router.back();
};
const changeCode = (value: string) => {
  form.value.code = value;
};
</script>

<style></style>
